/**
 * Copyright &copy; 2013-2016 山东易科德软件有限公司 All rights reserved.
 */
package cn.net.ecode.modules.cms.entity;

import java.util.Date;
import java.util.List;

import javax.validation.constraints.Pattern;

import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.NotBlank;

import cn.net.ecode.common.config.Global;
import cn.net.ecode.common.persistence.TreeEntity;
import cn.net.ecode.common.persistence.annotation.Id;
import cn.net.ecode.modules.cms.utils.CmsUtils;

import com.google.common.collect.Lists;

/**
 * 栏目Entity
 * @author ThinkGem
 * @version 2014-9-16
 */
public class Category extends TreeEntity<Category> {
	
    public static final String DEFAULT_TEMPLATE = "frontList"; // 默认文章列表模板

	private static final long serialVersionUID = 1L;
    
	private String categoryCode;// 分类编码
	private String categoryName;// 栏目名称
	private String viewCode;  // 显示的代码名称（仅作为显示用，集团内唯一）
	private Site site;			// 归属站点
	private String module; 		// 模块类型（article：文章；picture：图片；download：下载；link：链接；special：专题）
	private String image; 		// 栏目图片
	private String href; 		// 链接
	private String target; 		// 目标（ _blank、_self、_parent、_top）
	private String description; // 描述，填写有助于搜索引擎优化
	private String keywords; 	// 关键字，填写有助于搜索引擎优化
	private String inMenu; 		// 是否在导航中显示（1：显示；0：不显示）
	private String inList; 		// 是否在分类页中显示列表（1：显示；0：不显示）
	private String showModes; 	// 展现方式（0:有子栏目显示栏目列表，无子栏目显示内容列表;1：首栏目内容列表；2：栏目第一条内容）
	private String allowComment;// 是否允许评论
	private String isAudit;		// 是否需要审核
	private String customListView;		// 自定义列表视图
	private String customContentView;	// 自定义内容视图
    private String viewConfig;			// 视图参数
    
    private Date beginDate;	// 开始时间（查询统计）
    private Date endDate;	// 结束时间（查询统计）
    private String cnt;		//信息量（查询统计）
    private String hits;	//点击量（查询统计）
    
    private List<Integer> sortGradeList = Lists.newArrayList();		// 根据树的层级级别查询栏目列表
    private List<String> categoryCodeList = Lists.newArrayList();	// 根据分类栏目编号查询栏目列表
    private List<String> roleCodeList = Lists.newArrayList();		// 根据角色查询有权限的栏目列表
    
    private String siteCode;//站点编码
    private String url;
    
	public Category(){
		super();
		this.module = "";
		this.sorts = 30;
		this.showModes = "0";
		this.allowComment = Global.NO;
		this.isAudit = Global.NO;
	}

	public Category(String id){
		super(id);
	}
	
	public Category(String id, Site site){
		super(id);
		this.setSite(site);
	}
	
	@Id
	public String getCategoryCode() {
		return categoryCode;
	}

	public void setCategoryCode(String categoryCode) {
		this.categoryCode = categoryCode;
	}

	@Length(min=0, max=100)
	public String getCategoryName() {
		return categoryName;
	}

	public void setCategoryName(String categoryName) {
		this.categoryName = categoryName;
	}

	@Pattern(regexp="[a-zA-Z0-9_]{0,30}", message="编码长度不能大于 30 个字符，并且只能包含字母、数字、下划线")
	public String getViewCode() {
		return viewCode;
	}

	public void setViewCode(String viewCode) {
		this.viewCode = viewCode;
	}

	public Site getSite() {
		return site;
	}

	public void setSite(Site site) {
		this.site = site;
	}

	public Category getParent() {
		return parent;
	}

	public void setParent(Category parent) {
		this.parent = parent;
	}
	
	@Length(min=0, max=20)
	public String getModule() {
		return module;
	}

	public void setModule(String module) {
		this.module = module;
	}

	@Length(min=0, max=255)
	public String getImage() {
		return image;
	}

	public void setImage(String image) {
		this.image = image;
	}

	@Length(min=0, max=255)
	public String getHref() {
		return href;
	}

	public void setHref(String href) {
		this.href = href;
	}

	@Length(min=0, max=20)
	public String getTarget() {
		return target;
	}

	public void setTarget(String target) {
		this.target = target;
	}

	@Length(min=0, max=255)
	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	@Length(min=0, max=255)
	public String getKeywords() {
		return keywords;
	}

	public void setKeywords(String keywords) {
		this.keywords = keywords;
	}
	
//	@NotNull
//	public Integer getSort() {
//		return sort;
//	}
//
//	public void setSort(Integer sort) {
//		this.sort = sort;
//	}

	@Length(min=0, max=1)
	public String getInMenu() {
		return inMenu;
	}

	public void setInMenu(String inMenu) {
		this.inMenu = inMenu;
	}

	@Length(min=0, max=1)
	public String getInList() {
		return inList;
	}

	public void setInList(String inList) {
		this.inList = inList;
	}

	@Length(min=0, max=1)
	public String getShowModes() {
		return showModes;
	}

	public void setShowModes(String showModes) {
		this.showModes = showModes;
	}
	
	@Length(min=0, max=1)
	public String getAllowComment() {
		return allowComment;
	}

	public void setAllowComment(String allowComment) {
		this.allowComment = allowComment;
	}

	@Length(min=0, max=1)
	public String getIsAudit() {
		return isAudit;
	}

	public void setIsAudit(String isAudit) {
		this.isAudit = isAudit;
	}

	public String getCustomListView() {
		return customListView;
	}

	public void setCustomListView(String customListView) {
		this.customListView = customListView;
	}

	public String getCustomContentView() {
		return customContentView;
	}

	public void setCustomContentView(String customContentView) {
		this.customContentView = customContentView;
	}

    public String getViewConfig() {
        return viewConfig;
    }

    public void setViewConfig(String viewConfig) {
        this.viewConfig = viewConfig;
    }

	public Date getBeginDate() {
		return beginDate;
	}

	public void setBeginDate(Date beginDate) {
		this.beginDate = beginDate;
	}

	public Date getEndDate() {
		return endDate;
	}

	public void setEndDate(Date endDate) {
		this.endDate = endDate;
	}

	public String getCnt() {
		return cnt;
	}

	public void setCnt(String cnt) {
		this.cnt = cnt;
	}

	public String getHits() {
		return hits;
	}

	public void setHits(String hits) {
		this.hits = hits;
	}

	public List<Integer> getSortGradeList() {
		return sortGradeList;
	}

	public void setSortGradeList(List<Integer> sortGradeList) {
		this.sortGradeList = sortGradeList;
	}

	public List<String> getCategoryCodeList() {
		return categoryCodeList;
	}

	public void setCategoryCodeList(List<String> categoryCodeList) {
		this.categoryCodeList = categoryCodeList;
	}

	public List<String> getRoleCodeList() {
		return roleCodeList;
	}

	public void setRoleCodeList(List<String> roleCodeList) {
		this.roleCodeList = roleCodeList;
	}

   	

	public String getSiteCode() {
		return siteCode;
	}

	public void setSiteCode(String siteCode) {
		this.siteCode = siteCode;
	}

	public String getUrl() {
		return url;
	}

	public void setUrl(String url) {
		this.url = url;
	}

	public String getAdminUrl() {
		return CmsUtils.getAdminUrlDynamic(this);
	}
   	
}